home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-19 | 12.2 KB | 472 lines | [TEXT/pdos] |
- /* File: Rtutor.Rez */
- /* Rez source file for C version of resource tutorial */
- /* Part 1: starting up & shutting down the tools using a resource */
- /* Part 2: do Part 1 and insert a menubar with menus */
- /* Part 2.5: do part 2 and add an event loop so app stays up */
- /* Part 3: do part 2.5 and add a window (w/ controls) from a resource */
-
- /* this gives use access to the "standard" pre-defined resource types */
- #include "Types.rez"
-
- /*---------------------- Startup Record ---------------------------*/
- resource rToolStartup (1)
- {
- $C080, /* set master SCB to mode640 + fFastPortAware + fUseShadowing */
- {
- 3,$0300, /* misc tools */
- 4,$0302, /* quickdraw */
- 5,$0302, /* desk manager */
- 6,$0300, /* eventMgr */
- /* 7,$0300, /* scheduler */ /* not used by apps or DA's */
- /* 8,$0301, /* sound tools */ /* not used by this app */
- /* 9,$0300, /* ADB tools */ /* not used by this app */
- /* 10,$0300, /* SANE */ /* started already by pStart.obj */
- 11,$0300, /* int math */
- 14,$0301, /* Window Manager */
- 15,$0301, /* Menu Manager */
- 16,$0300, /* Control Manager */
- 18,$0301, /* QD Aux */
- 19,$0300, /* print manager */
- 20,$0301, /* LineEdit tool set */
- 21,$0302, /* Dialog Manager */
- 22,$0300, /* Scrap manager */
- 23,$0301, /* standard file */
- 27,$0301, /* Font manager */
- 28,$0301, /* list manager */
- 34,$0101, /* text edit */
- /* 29,$0100, /* ACE */ /* not used by this app */
- /* 32,$0100, /* Midi Tools */ /* not used by this app */
- /* 25,$0100, /* NoteSynth */ /* not used by this app */
- /* 26,$0100 /* Note Seq */ /* not used by this app */
- }
- };
-
-
- /*---------------------- Menus & Menu Bars ---------------------------*/
- /* define the resource id of the menu bar itself */
- #define kMenuBarID1 1
-
- /* define all the menu id's */
- #define kAppleMID 1000
- #define kFileMID 2000
- #define kEditMID 3000
-
- /* now, define the menu item id's */
- #define kAboutBoxIID 1001 /* the "About..." box */
-
- #define kNewItem 2001 /* the "New" item */
- #define kOpenItem 2002 /* the "Open..." item */
- #define kCloseItem 255 /* the "Close" item */
- #define kSaveItem 2004 /* the "Save" item */
- #define kSaveAsItem 2005 /* the "Save As..." item */
- #define kQuitItem 2009 /* the "Quit" item */
-
- #define kUndoItem 250 /* the "Undo" item */
- #define kCutItem 251 /* the "Cut" item */
- #define kCopyItem 252 /* the "Copy" item */
- #define kPasteItem 253 /* the "Paste" item */
- #define kClearItem 254 /* the "Clear" item */
- #define kSelectItem 3001 /* the "Select All" item */
- #define kShowClipItem 3002 /* the "Show Clipboard" item */
-
- /* now, define the menu bar */
- resource rMenuBar (kMenuBarID1)
- {
- {
- kAppleMID,
- kFileMID,
- kEditMID,
- };
- };
-
-
- /* lay out the Apple menu */
- /* this takes several steps: */
- /* 1) define the menu itself in a resource of type "rMenu" */
- /* 2) define the rPString that will be used for the name of the menu */
- /* 3) define the first item in the menu in a resource of type "rMenuItem" */
- /* 4) define the rPString that will be used for the name of the first item */
- /* 5) repeat steps 3 and 4 for all remaining items in that menu */
- /* 6) repeat steps 1 through 5 for all remaining menus */
-
- resource rMenu (kAppleMID, nocrossbank)
- {
- kAppleMID, /* ID of the menu this item belongs to */
- 0xA008, /* flags => menu title is a resource, items are resources, menu */
- /* is enabled, XOR highlighting, std menu, caching ok */
- kAppleMID, /* ref to menu's title */
- { kAboutBoxIID }; /* array of items in this menu (only 1 to start with) */
- };
-
- resource rPString (kAppleMID, nocrossbank)
- {
- "@" /* this string is the title of the "Apple" menu */
- };
-
- /* see IIGS Toolbox Reference, Volume 3, menu item template */
- resource rMenuItem (kAboutBoxIID, nocrossbank)
- {
- kAboutBoxIID, /* item's ID */
- "", /* no keyboard equivalent */
- "", /* no keyboard equivalent (allowed 2, this is the 2nd) */
- 0, /* this item does not have a check mark by it */
- 0x8040, /* title is in a resource, enabled (bit 7=0), */
- /* dividing line below (bit 6=1) */
- kAboutBoxIID /* ref of the item's title */
- };
-
- resource rPString (kAboutBoxIID, nocrossbank)
- {
- "About rTutor" /* used as the title for the "About..." item */
- };
-
-
- /* lay out the File menu */
-
- resource rMenu (kFileMID, nocrossbank)
- {
- kFileMID, /* ID of the menu this item belongs to */
- 0xA008, /* flags => menu title is a resource, items are resources, */
- /* menu is enabled, don't use XOR highlighting, std menu, */
- /* caching ok */
- kFileMID, /* ref to menu's title */
- { /* array of items in this menu */
- kNewItem,
- kOpenItem,
- kCloseItem,
- kSaveItem,
- kSaveAsItem,
- kQuitItem
- };
- };
-
- resource rPString (kFileMID, nocrossbank)
- {
- " File " /* this string is the title of the "File" menu */
- };
-
- resource rMenuItem (kNewItem, nocrossbank)
- {
- kNewItem, /* item's ID */
- "N", /* keyboard equivalent = "N" */
- "n", /* or = "n" (either key will work) */
- 0, /* this item does not have a check mark by it */
- 0x8000, /* title is in a resource, enabled (bit 7 = 0) */
- kNewItem /* ref of the item's title */
- };
-
- resource rPString (kNewItem, nocrossbank)
- {
- "New" /* this string is used as the title for the "New" item */
- };
-
- resource rMenuItem (kOpenItem, nocrossbank)
- {
- kOpenItem,
- "O", /* that's an "OH" on this line, not a "zero" */
- "o", /* that's an "OH" on this line, not a "zero" */
- 0, /* this one's a "zero" */
- 0x8040, /* the "4" means put a dividing line under this item */
- kOpenItem
- };
-
- resource rPString (kOpenItem, nocrossbank)
- {
- "Open..."
- };
-
- resource rMenuItem (kCloseItem, nocrossbank)
- {
- kCloseItem,
- "W",
- "w",
- 0,
- 0x8000,
- kCloseItem
- };
-
- resource rPString (kCloseItem, nocrossbank)
- {
- "Close"
- };
-
- resource rMenuItem (kSaveItem, nocrossbank)
- {
- kSaveItem,
- "S",
- "s",
- 0,
- 0x8000,
- kSaveItem
- };
-
- resource rPString (kSaveItem, nocrossbank)
- {
- "Save"
- };
-
- resource rMenuItem (kSaveAsItem, nocrossbank)
- {
- kSaveAsItem,
- "", /* no key equivalents for this item */
- "",
- 0,
- 0x8000,
- kSaveAsItem
- };
-
- resource rPString (kSaveAsItem, nocrossbank)
- {
- "Save As..."
- };
-
- resource rMenuItem (kQuitItem, nocrossbank)
- {
- kQuitItem,
- "Q",
- "q",
- 0,
- 0x8000,
- kQuitItem
- };
-
- resource rPString (kQuitItem, nocrossbank)
- {
- "Quit"
- };
-
-
- /* lay out the Edit menu */
-
- resource rMenu (kEditMID, nocrossbank)
- {
- kEditMID, /* ID of the menu this item belongs to */
- 0xA008,
- kEditMID, /* ref to menu's title */
- { /* array of items in this menu */
- kUndoItem,
- kCutItem,
- kCopyItem,
- kPasteItem,
- kClearItem,
- kSelectItem,
- kShowClipItem
- };
- };
-
- resource rPString (kEditMID, nocrossbank)
- {
- " Edit " /* this string is the title of the "Edit" menu */
- };
-
- resource rMenuItem (kUndoItem, nocrossbank)
- {
- kUndoItem,
- "Z",
- "z",
- 0,
- 0x8040,
- kUndoItem
- };
-
- resource rPString (kUndoItem, nocrossbank)
- {
- "Undo"
- };
-
- resource rMenuItem (kCutItem, nocrossbank)
- {
- kCutItem,
- "X",
- "x",
- 0,
- 0x8000,
- kCutItem
- };
-
- resource rPString (kCutItem, nocrossbank)
- {
- "Cut"
- };
-
- resource rMenuItem (kCopyItem, nocrossbank)
- {
- kCopyItem,
- "C",
- "c",
- 0,
- 0x8000,
- kCopyItem
- };
-
- resource rPString (kCopyItem, nocrossbank)
- {
- "Copy"
- };
-
- resource rMenuItem (kPasteItem, nocrossbank)
- {
- kPasteItem,
- "V",
- "v",
- 0,
- 0x8000,
- kPasteItem
- };
-
- resource rPString (kPasteItem, nocrossbank)
- {
- "Paste"
- };
-
- resource rMenuItem (kClearItem, nocrossbank)
- {
- kClearItem,
- "",
- "",
- 0,
- 0x8000,
- kClearItem
- };
-
- resource rPString (kClearItem, nocrossbank)
- {
- "Clear"
- };
-
- resource rMenuItem (kSelectItem, nocrossbank)
- {
- kSelectItem,
- "A",
- "a",
- 0,
- 0x8040, /* the "4" means this one has a divider under it */
- kSelectItem
- };
-
- resource rPString (kSelectItem, nocrossbank)
- {
- "Select All"
- };
-
- resource rMenuItem (kShowClipItem, nocrossbank)
- {
- kShowClipItem,
- "",
- "",
- 0,
- 0x8000,
- kShowClipItem
- };
-
- resource rPString (kShowClipItem, nocrossbank)
- {
- "Show Clipboard"
- };
-
-
- /*---------------------- Windows and their contents --------------------------*/
- /* define the resource ID's for all windows used by this app */
- #define myWindowID 2362 /* window's resource ID = 2362 */
-
- /* First, we lay out the window itself */
- resource rWindParam1 (myWindowID)
- {
- fTitle+fMove+fVis, /* has a title, can be moved, and it is visible */
- myWindowID, /* resource ID of the title */
- 0, /* no ref Con needed */
- {0,0,0,0}, /* no zoom box, so we don't care about the zoom rect */
- 0, /* use std color table for now */
- {0,0}, /* upper left corner of vis rgn = upper left of document */
- {0,0}, /* we don't really have a "document" for this window, so */
- /* set the data size to zero */
- {0,0}, /* maximum height and width */
- {0,0}, /* don't scroll vertically or horizontally */
- {0,0}, /* no "document", so page size is zero also */
- 0, /* passed to info bar draw routine - not used here */
- 0, /* height of info bar - not used here */
- {46,100,176,540}, /* this rect defines the boundaries of the window */
- infront, /* window comes up in front of other windows */
- 0, /* set to NIL to avoid bug in NewWindow2 */
- refIsResource*0x0100+resourceToResource /* title string and */
- /* control list are resources */
- };
-
- /* define the title string used by our window */
- resource rPstring (myWindowID)
- {
- " This came from a resource "
- };
-
-
- /* define the list of controls that are in the default window */
- /* we're taking it easy for now and are putting in only: */
- /* a simple round button and a text edit field */
- /* so, we need to define the constants used by those controls */
-
- #define myRoundButton $0001
- #define myTEField $0002
-
- resource rControlList (myWindowID)
- {
- {
- myRoundButton,
- myTEField,
- };
- /* last item in a control list HAS to be NIL, but the template for a */
- /* rControlList takes care of sticking the NIL in there for us! */
- };
-
- /* define the simple round button */
- resource rControlTemplate (myRoundButton)
- {
- myRoundButton, /* ID of this control */
- {8,152, 22, 290}, /* boundary rect for button */
- SimpleButtonControl /* type of control */
- {
- {
- 0, /* button is visible and has simple rounded corners */
- 0x1002, /* bit 12 MUST be set!!! and title is in a resource */
- 0, /* ignore the ref con */
- myRoundButton /* resource ID of title string */
- }
- };
- };
-
- /* define the title string used by the simple button */
- resource rpString (myRoundButton)
- {
- "Rent this space"
- };
-
- /* define the text edit field */
- resource rControlTemplate (myTEField)
- {
- myTEField, /* ID of the text edit control */
- {30,10,120,430}, /* bounding rectangle for the text edit field */
- EditTextControl /* type of control */
- {
- {
- 0x0000, /* field is visible ("flag" field") */
- 0x7400, /* see Toolbox Ref, volume 3 for details */
- 0, /* ignore the ref con */
- 0x42A80000, /* text flags - see Toolbox Ref, volume 3 */
- {$FFFF,$FFFF,$FFFF,$FFFF}, /* use std values for indent rect */
- $FFFFFFFF, /* allow vertical scroll bar */
- 0, /* use default vertical scroll amount */
- 0, /* horzBar - MUST be NIL */
- 0, /* horzAmount - MUST be zero */
- 0, /* use default style and ruler info */
- dataIsPString+RefIsResource*8, /* default text is in a rPstring resource */
- myTEField, /* resource ID of default text */
- 0 /* text length - set by toolbox when text resource is read in */
- }
- };
- };
-
- /* define the text that will show up when the text edit field is created */
- resource rPString (myTEField)
- {
- "Try selecting this text, then pick COPY, CUT, and/or PASTE from the EDIT menu."
- };
-